package restless.utilities.testing {
	import flash.display.*;
	import flash.display3D.VertexBuffer3D;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.geom.Vector3D;
	import flash.utils.*;
	import flash.text.*;
	import flash.system.System;
	import restless.utilities.geom.RLERect;
	
	public class SpeedTest extends Sprite {
		private var __logger:TextField = new TextField();
		private var s:String = "";
		
		private function row(...cols): void {
			__logger.appendText(cols.join(", ") + "\n");
		}
		
		public function SpeedTest() {
			__logger.autoSize = TextFieldAutoSize.LEFT;
			addChild(__logger);
			var bitmap:Bitmap = new Bitmap;
			var bitmapData:BitmapData = new BitmapData(mc.width, mc.height);
			var vHolder:Vector.<Vector.<BitmapData>> = new Vector.<Vector.<BitmapData>>;
			var vImage:Vector.<BitmapData> = new Vector.<BitmapData>;
			var tempV:Vector3D;
			var tempBool:Boolean;
			var frames:int = mc.totalFrames;
			var point:Point = new Point(0, 0);
			var tempBitmapData:BitmapData;
			var rec:Rectangle;
			var v3D:Vector3D = new Vector3D(1, 2, 3, 4);
			var bool:Boolean = true;
			var shp:Shape = new Shape();
			for (var j:int = 0; j < frames; j++) {
				mc.gotoAndStop(j + 1);
				bitmapData = new BitmapData(mc.width, mc.height);
				bitmapData.lock();
				bitmapData.draw(mc);
				bitmapData.unlock();
				vImage.push(bitmapData);
			}
			
			var h:Number;
			var w:Number;
			
			var i:int = 0;
			bitmap.bitmapData = bitmapData;
			trace(bitmapData.width);
			
			//stage.addChild(bitmap);
			var stringFunct:String = "someFunct";
			var beforeTime:int;
			var afterTime:int;
			var castTime:int;
			//var i:uint;
			var len:uint = 10000;
			trace("itterations: " + len);
			
			
			beforeTime = getTimer();
			for (i = 0; i < len; ++i) {
				tempV = someVector3D();
				
			}
			afterTime = getTimer();
			castTime = afterTime - beforeTime;
			row("RLERect ", castTime);
			
			
			beforeTime = getTimer();
			for (i = 0; i < len; ++i) {
				tempBool = someBoolean();
				
			}
			afterTime = getTimer();
			castTime = afterTime - beforeTime;
			row("VBitmapData Bit parse ", castTime);
			
		}
		
		private function someVector3D():Vector3D {
			return v3D;
		}
		
		private function someBoolean():Boolean {
			return bool;
		}
		
	}
}
